package cn.bugstack.domain.strategy.model.valobj;

import cn.bugstack.domain.strategy.service.rule.filter.factory.DefaultLogicFactory;
import cn.bugstack.types.common.Constants;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Arrays;

/**
 * @Title: StrategyAwardRuleModelVO
 * @Author lz
 * @Date 2025/8/1 15:30
 * @description: 抽奖策略规则值对象：没有唯一ID，仅限于从数据库查询对象
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class StrategyAwardRuleModelVO {
    private String ruleModels;
    //获取抽奖中规则
    public String[] raffleCenterRuleModelList(){//选择类型是center的规则
       return Arrays.stream(ruleModels.split(Constants.SPLIT))
                .filter(DefaultLogicFactory.LogicModel::isCenter)
                .toArray(String[]::new);//将list数组转换为数组
//        List<String> ruleModelList =new ArrayList<>();
//        String[] ruleModelValues = ruleModels.split(Constants.SPLIT);
//        for (String ruleModelValue : ruleModelValues){
//            if (DefaultLogicFactory.LogicModel.isCenter(ruleModelValue)){
//                ruleModelList.add(ruleModelValue);
//            }
//        }
//        return ruleModelList.toArray(new String[0]);
    }
    public String[] raffleAfterRuleModelList(){
      return  Arrays.stream(ruleModels.split(Constants.SPLIT))
              .filter(DefaultLogicFactory.LogicModel::isAfter)
              .toArray(String[]::new);
    }
}
